﻿using System;
using System.Configuration;
using System.Linq;
using System.Reflection;
using EvincePayroll.Communication;
using EvincePayroll.Data;
using EvincePayroll.Utility;
using System.Configuration;
using EvincePayroll.Communication.Database;

namespace EvincePayroll.Communication
{
    public class CommunicationFactory
    {
        public IDatabaseRepository GetDatabasefacotry
        {
            get
            {

                string _DatabaseRepository = ConfigurationManager.AppSettings["DatabaseRepository"];
                if (!String.IsNullOrEmpty(_DatabaseRepository))
                {
                    Type obj = Type.GetType(_DatabaseRepository);
                    ConstructorInfo constructor = obj.GetConstructor(new Type[] { });
                    return (IDatabaseRepository)constructor.Invoke(null);
                }

                return new DatabaseRepository();
            }
        }
    }
}
